<script>
import Vue from 'vue';
import { Config, Tools, VueTools } from '@/common/tools.js';
export default {
	onLaunch: function() {
		uni.getSystemInfo({
			success: function(e) {
				Vue.prototype.$window = e;
				Vue.prototype.statusBar = e.statusBarHeight;
				// #ifndef MP
				if (e.platform == 'android') {
					Vue.prototype.customBar = e.statusBarHeight + 24;
				} else {
					Vue.prototype.customBar = e.statusBarHeight + 24;
				}
				// #endif

				// #ifdef H5
				Vue.prototype.customBar = e.statusBarHeight + 50;
				// #endif

				// #ifdef MP-WEIXIN
				let custom = wx.getMenuButtonBoundingClientRect();
				Vue.prototype.customBar = custom.bottom + custom.top - e.statusBarHeight;
				// #endif

				// #ifdef MP-ALIPAY
				Vue.prototype.customBar = e.statusBarHeight + e.titleBarHeight;
				// #endif
			}
		});
		// #ifdef APP-PLUS
		this.Tab.getInstance().create();
		this.Tab.getInstance().show(false);
		this.Tab.getInstance().setOnClickListener(() => {
			if (this.$store.state.tabbar_now_index != 2 || this.$store.state.tabbar_now_index != '2') {
				if (!Config.is3rd) {
					uni.switchTab({
						url: '/pages/home/home'
					});
				} else {
					uni.switchTab({
						url: '/pages/home/home3rd'
					});
				}

				this.Tab.getInstance().show(false);
				this.$store.commit('setTabbarIndex', 2);
			}
		});
		// #endif
		//第一次进入app判断是否登陆
		this.isLogin();
		// 获取并存储邀请码的值
		// #ifdef H5
		this.storeInvite();
		// #endif
	},
	onShow: function() {},
	onHide: function() {
		console.log('App Hide');
	},
	methods: {
		/**
		 * 存储通过路由过来的邀请码的值
		 */
		storeInvite() {
			let tempUrl = window.location.href;
			let tempTarget = tempUrl.split('?');
			if (tempTarget.length >= 2) {
				let incode = Tools.urlToObj(tempTarget[1])['incode'];
				if (!Tools.isEmpty(parseInt(incode))) {
					VueTools.setStorageSync(Config.INCODE, parseInt(incode));
				}
			}
		}
	}
};
</script>

<style lang="scss">
/* 引入的iconfont的字体文件 */
@import url('./static/fonts/iconfont.css');
/*全局的scss文件*/
@import './static/css/global.scss';
/*每个页面公共css */
//底部的tabbar的中间的样式
/* #ifdef  H5 */
.uni-tabbar {
	.uni-tabbar__item:nth-child(4) {
		position: relative;
		> .uni-tabbar__bd {
			position: absolute;
			height: 70px;
		}
		.uni-tabbar__icon {
			margin-top: -20px;
			overflow: visible;
			width: 47px;
			height: 47px;
			line-height: 47px;
			border-radius: 50%;
			background: #fff;
			border: 5px solid #fff;
			box-shadow: 0 -2px 3px rgba(100, 100, 100, 0.4);
		}
	}
}
/* #endif */
</style>
